package com.dudy.spring1;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

/**
 * @author <a href="mailto:wb-zhaojunwei@alibaba-inc.com">wb-zhaojunwei</a>
 * @version 1.0
 * @Description spring事件处理机制观察者
 * @Since 2016/5/25
 */
public class SpringObserver implements ApplicationListener {
    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        if (event instanceof SpringSubject) {
            SpringSubject ss = (SpringSubject) event;
            System.out.println("地址为：" + ss.getAddress());
            System.out.println("内容为：" + ss.getText());
        } else {
            System.out.println("容器本身为：" + event);
        }
    }
}
